package com.mr.biz.impl;

import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Repository;

import com.mr.biz.CategoryRepository;
import com.mr.biz.support.AbstractRepository;
import com.mr.biz.support.Response;
import com.mr.dao.entity.product.Category;
import com.mr.dao.service.EntityService;

/**
 * @author Alex
 */
@Repository
public class CategoryRepositoryImpl extends AbstractRepository implements CategoryRepository {

	@Resource
	private EntityService<Category> entityService;

	@Override
	public Response load() throws Exception {
		List<Category> categories = entityService.findAll(Category.class);

		Map<String, Object> root = createRoot();
		root.put("categories", categories);
		return generateResponseWithFreeMarker(root, "CategoryRepository-load");
	}
}
